package com.dulichdanang.location.locations;

import java.util.ArrayList;
import java.util.List;

import com.dulichdanang.R;
import com.dulichdanang.location.location.Location;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class LocationsAdatper extends BaseAdapter{
	Context mContext;
	LayoutInflater li;
	List<Location> items = new ArrayList<Location>();
	//public static final int ACTIVITY_CREATE = 10;
	public LocationsAdatper(Context c,List<Location> _items){
		mContext = c;
		li =  (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		items = _items;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.size();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v;
		Location location = items.get(position);
		if(convertView==null){
			
//			v = li.inflate(R.layout.griditem_location, null);
//			TextView tv = (TextView)v.findViewById(R.id.tvLocation);
//			tv.setText(location.name);
//			ImageView iv = (ImageView)v.findViewById(R.id.imgLocation);
//			iv.setImageResource(location.imageResource);
			v = li.inflate(R.layout.listitem_location, null);
			TextView tvName = (TextView)v.findViewById(R.id.tvListLocationName);
			TextView tvAddress = (TextView)v.findViewById(R.id.tvListLocationAddress);
			TextView tvAdd = (TextView)v.findViewById(R.id.tvListLocationAdd);
			tvName.setText(location.name);
			tvAddress.setText(location.address);
			tvAdd.setText(location.share);
		}
		else
		{
			v = convertView;
		}
		return v;
	}
	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}
}
